import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hook_up_rent/widgets/info/data.dart';
import 'package:hook_up_rent/widgets/info/info_list_item.dart';

class InfoList extends StatelessWidget {
  final bool showTitle;
  final List<InfoItem> dataList;
  const InfoList({Key key, this.showTitle = false, this.dataList = infoData}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          _buildInfoTitle(),
          _buildInfoList()
        ],
      ),
    );
  }
  Widget _buildInfoTitle(){
    if(showTitle){
      return Container(
        padding: EdgeInsets.all(10.0),
        alignment: Alignment.centerLeft,
        child: Text("最新资讯",style: TextStyle(fontSize: 18,fontWeight: FontWeight.bold),),
      );
    }else{
      return Container();
    }
  }
  _buildInfoList(){
    return Column(
      children: dataList.map((item) => InfoListItem(item)).toList(),
    );
  }
}
